scheduleRuleModule.controller("ScheduleAttendanceConfigCtrl", ["$log", "$timeout", "$scope", "$modal", "providerSvc", "aresDialog", "$q", "scheduleSvc", "loginContext", "practiceSvc", "appNav", function(n, t, i, r, u, f, e, o, s, h, c) {
    "use strict";
    i.radius = "未设置";
    var l = [{
            id: 0,
            name: "0米"
        }, {
            id: 100,
            name: "100米"
        }, {
            id: 200,
            name: "200米"
        }, {
            id: 300,
            name: "300米"
        }, {
            id: 400,
            name: "400米"
        }, {
            id: 500,
            name: "500米"
        }, {
            id: 600,
            name: "600米"
        }, {
            id: 700,
            name: "700米"
        }, {
            id: 800,
            name: "800米"
        }, {
            id: 900,
            name: "900米"
        }],
        v = function(n) {
            for (var u, r = 0, t = 0; t < l.length; t++) l[t].id == n && (r = t);
            u = $("#radiusDropdown");
            u.kendoDropDownList({
                dataSource: l,
                placeholder: "",
                dataTextField: "name",
                dataValueField: "id",
                index: r,
                select: function(n) {
                    var t = this.dataItem(n.item.index());
                    i.radius = t.id;
                    i.currentOffice.officeLocaltion.radius = t.id
                }
            })
        },
        y = function() {
            var t, n, r;
            for (i.defaultClass = "label-hide", i.defaultHideClass = "label-show", i.isEditMode = !0, t = 0, n = 0; n < l.length; n++) i.currentOffice && i.currentOffice.officeLocaltion && l[n].id == i.currentOffice.officeLocaltion.radius && (t = n);
            r = $("#radiusDropdown").data("kendoDropDownList");
            r.select(t)
        },
        p = function() {
            window.Ares3 ? c.goToEnterpriseCenter() : c.switchState("officeSettings.info")
        },
        a = function() {
            i.defaultClass = "label-show";
            i.defaultHideClass = "label-hide";
            i.isEditMode = !1
        },
        w = function() {
            if (i.isAllowAttendance && (!i.currentOffice.officeLocaltion.location || !i.currentOffice.officeLocaltion.radius)) {
                f.warn("提示", "当用启用考勤时，需要地理位置不为空且打卡有效范围不能为0米！");
                return
            }
            h.updateOffice(i.currentOffice).success(function() {});
            k();
            a()
        },
        b = function() {
            i.initRadiusDropdown(i.radius);
            h.getFullOffice(i.officeId).success(function(n) {
                n && !n.officeLocaltion && (n.officeLocaltion = {
                    radius: 0
                });
                i.currentOffice = n
            });
            h.getSystemConfigByName("IsAllowAttendance").success(function(n) {
                n && (i.systemConfig = n, i.isAllowAttendance = n.configValue.toUpperCase() == "TRUE" ? !0 : !1)
            })
        },
        k = function() {
            i.systemConfig.configValue = i.isAllowAttendance ? "true" : "false";
            h.updateSystemConfig(i.systemConfig).success(function() {})
        };
    (function() {
        i.officeId = s.officeId;
        i.isAllowAttendance = !1;
        i.isEditMode = !1;
        i.editConfig = y;
        i.showConfig = a;
        i.saveConfig = w;
        i.initRadiusDropdown = v;
        i.goToNavigation = p;
        b()
    })()
}]);
scheduleRuleModule.controller("ScheduleAttendanceDayListCtrl", ["$log", "$timeout", "$scope", "$modal", "providerSvc", "aresDialog", "$q", "scheduleSvc", function(n, t, i, r, u, f, e, o) {
    "use strict";
    var s, h = function() {
            var t = Ares.today(),
                n = moment(t).format("YYYY-MM-DD");
            s = {
                startDate: n,
                endDate: n
            };
            i.timeSpan = _.clone(s)
        },
        a = function() {
            var t = e.defer(),
                r = i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : s.startDate,
                n = i.timeSpan.endDate ? moment(i.timeSpan.endDate).format("YYYY-MM-DD") : s.endDate;
            return n = i.defaultSelect ? moment(r).add(1, "days").format("YYYY-MM-DD") : moment(n).add(1, "days").format("YYYY-MM-DD"), i.criteria = {
                providerIds: i.getProviders(),
                startDate: moment(r).format("YYYY-MM-DD"),
                endDate: n
            }, o.getAttendanceDayScheduleList(i.criteria).success(function(n) {
                i.count = n ? n.length : 0;
                i.pageData = n;
                v(i.pageData);
                t.resolve(!0)
            }), t.promise
        },
        c = function(n) {
            switch (n) {
                case 0:
                    return "未知";
                case 1:
                    return "迟到";
                case 2:
                    return "早退";
                case 3:
                    return "正常";
                case 4:
                    return "缺卡";
                case 5:
                    return "无效";
                case 6:
                    return "未配置考勤"
            }
        },
        v = function(n) {
            angular.forEach(n, function(n) {
                n.attendanceDateStr = moment(n.attendanceDate).format("YYYY-MM-DD");
                n.onDutyTimeStr = n.onDutyTime ? moment(n.onDutyTime).format("HH:mm") : "";
                n.onDutyScheduleTimeStr = n.onDutyScheduleTime ? moment(n.onDutyScheduleTime).format("HH:mm") : "";
                n.onDutyStateStr = c(n.onDutyState);
                n.offDutyTimeStr = n.offDutyTime ? moment(n.offDutyTime).format("HH:mm") : "";
                n.offDutyScheduleTimeStr = n.offDutyScheduleTime ? moment(n.offDutyScheduleTime).format("HH:mm") : "";
                n.offDutyStateStr = c(n.offDutyState);
                n.isOnDutyStr = n.isOnDuty ? "出诊" : "不出诊";
                n.providerName = n.provider ? n.provider.name : "";
                n.providerNo = n.provider ? n.provider.employeeNo : ""
            })
        },
        l = function(n) {
            y().then(function() {
                a(n).then(function() {
                    p().then(function() {
                        b();
                        k()
                    })
                })
            })
        },
        y = function() {
            var n = e.defer();
            return u.getOtherProvider().success(function() {
                n.resolve(!0)
            }), n.promise
        },
        p = function() {
            var n = e.defer(),
                t = [];
            return angular.forEach(i.pageData, function(n) {
                t.push(n.itemName)
            }), i.chargeCategorys = t, n.resolve(!0), n.promise
        },
        w = function() {
            h();
            l("load")
        },
        b = function() {
            i.gridColumns = [];
            i.gridColumns.push({
                field: "attendanceDateStr",
                title: "日期",
                headerTemplate: "日期",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "providerName",
                title: "姓名",
                headerTemplate: "姓名",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "providerNo",
                title: "员工号",
                headerTemplate: "员工号",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "isOnDutyStr",
                title: "是否出诊",
                headerTemplate: "是否出诊",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "scheduleName",
                title: "排班名称",
                headerTemplate: "排班名称",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "onDutyScheduleTimeStr",
                title: "上班时间",
                headerTemplate: "上班时间",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "onDutyTimeStr",
                title: "上班打卡时间",
                headerTemplate: "上班打卡时间",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "onDutyStateStr",
                title: "上班状态",
                headerTemplate: "上班状态",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "offDutyScheduleTimeStr",
                title: "下班时间",
                headerTemplate: "下班时间",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "offDutyTimeStr",
                title: "下班打卡时间",
                headerTemplate: "下班打卡时间",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "offDutyStateStr",
                title: "下班状态",
                headerTemplate: "下班状态",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            })
        },
        k = function() {
            var n = [],
                t = [];
            angular.forEach(i.pageData, function(i) {
                var r = {};
                r.attendanceDateStr = i.attendanceDateStr;
                r.providerName = i.providerName;
                r.providerNo = i.providerNo;
                r.isOnDutyStr = i.isOnDutyStr;
                r.scheduleName = i.scheduleName;
                r.onDutyScheduleTimeStr = i.onDutyScheduleTimeStr;
                r.onDutyTimeStr = i.onDutyTimeStr;
                r.onDutyStateStr = i.onDutyStateStr;
                r.onDutyAddress = i.onDutyAddress;
                r.onDutyDeviceType = i.onDutyDeviceType;
                r.onDutyDeviceCode = i.onDutyDeviceCode;
                r.offDutyScheduleTimeStr = i.offDutyScheduleTimeStr;
                r.offDutyTimeStr = i.offDutyTimeStr;
                r.offDutyStateStr = i.offDutyStateStr;
                r.offDutyAddress = i.offDutyAddress;
                r.offDutyDeviceType = i.offDutyDeviceType;
                r.offDutyDeviceCode = i.offDutyDeviceCode;
                n.push(r);
                t.push(i.providerName)
            });
            i.dataSource = n
        };
    (function() {
        i.defaultSelect = !0;
        i.isFirstRecordOnly = !0;
        i.search = l;
        i.jobName = "员工";
        w();
        i.$watch("defaultSelect", function() {
            if (i.defaultSelect) h();
            else {
                var n = Ares.today(),
                    t = moment(n).startOf("month").format("YYYY-MM-DD"),
                    r = moment(n).startOf("month").add(1, "month").add(-1, "days").format("YYYY-MM-DD");
                i.timeSpan = {
                    startDate: t,
                    endDate: r
                }
            }
        })
    })()
}]);
scheduleRuleModule.controller("ScheduleAttendanceListCtrl", ["$log", "$timeout", "$scope", "$modal", "providerSvc", "aresDialog", "$q", "scheduleSvc", function(n, t, i, r, u, f, e, o) {
    "use strict";
    var s, h = function() {
            var t = Ares.today(),
                n = moment(t).format("YYYY-MM-DD");
            s = {
                startDate: n,
                endDate: n
            };
            i.timeSpan = _.clone(s)
        },
        d = function(n) {
            return _.filter(n, function(n) {
                return n.firstRecord != null || n.lastRecord != null
            })
        },
        l = function() {
            var t = e.defer(),
                r = i.timeSpan.startDate ? moment(i.timeSpan.startDate).format("YYYY-MM-DD") : s.startDate,
                n = i.timeSpan.endDate ? moment(i.timeSpan.endDate).format("YYYY-MM-DD") : s.endDate;
            return n = i.defaultSelect ? moment(r).add(1, "days").format("YYYY-MM-DD") : moment(n).add(1, "days").format("YYYY-MM-DD"), i.criteria = {
                providerIds: i.getProviders(),
                startTime: moment(r).format("YYYY-MM-DD"),
                endTime: n
            }, o.getAttendanceScheduleList(i.criteria).success(function(n) {
                i.count = n ? n.length : 0;
                i.pageData = n;
                v(i.pageData);
                t.resolve(!0)
            }), t.promise
        },
        a = function(n) {
            switch (n) {
                case 0:
                    return "未知";
                case 1:
                    return "上班";
                case 2:
                    return "下班"
            }
        },
        v = function(n) {
            angular.forEach(n, function(n) {
                n.recordTime = moment(n.recordTime).format("HH:mm");
                n.attendanceTypeStr = a(n.attendanceType)
            })
        },
        c = function(n) {
            y().then(function() {
                l(n).then(function() {
                    p().then(function() {
                        b();
                        k()
                    })
                })
            })
        },
        y = function() {
            var n = e.defer();
            return u.getOtherProvider().success(function() {
                n.resolve(!0)
            }), n.promise
        },
        p = function() {
            var n = e.defer(),
                t = [];
            return angular.forEach(i.pageData, function(n) {
                t.push(n.itemName)
            }), i.chargeCategorys = t, n.resolve(!0), n.promise
        },
        w = function() {
            h();
            c("load")
        },
        b = function() {
            i.gridColumns = [];
            i.gridColumns.push({
                field: "recordDate",
                title: "日期",
                headerTemplate: "日期",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "providerName",
                title: "姓名",
                headerTemplate: "姓名",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "attendanceTypeStr",
                title: "打卡类型",
                headerTemplate: "打卡类型",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "state",
                title: "打卡状态",
                headerTemplate: "打卡状态",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "recordTime",
                title: "打卡时间",
                headerTemplate: "打卡时间",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "address",
                title: "打卡位置",
                headerTemplate: "打卡位置",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "deviceType",
                title: "设备类型",
                headerTemplate: "设备类型",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            });
            i.gridColumns.push({
                field: "deviceCode",
                title: "设备ID",
                headerTemplate: "设备ID",
                width: "150px",
                format: "",
                aggregates: ["sum"],
                footerTemplate: ""
            })
        },
        k = function() {
            var n = [],
                t = [];
            angular.forEach(i.pageData, function(i) {
                var r = {};
                r.recordDate = i.recordDate;
                r.providerName = i.providerName;
                r.attendanceTypeStr = i.attendanceTypeStr;
                r.state = i.state;
                r.recordTime = i.recordTime;
                r.deviceType = i.deviceType;
                r.deviceCode = i.deviceCode;
                r.address = i.address;
                n.push(r);
                t.push(i.providerName)
            });
            i.dataSource = n
        };
    (function() {
        i.defaultSelect = !0;
        i.isFirstRecordOnly = !0;
        i.search = c;
        i.jobName = "员工";
        w();
        i.$watch("defaultSelect", function() {
            if (i.defaultSelect) h();
            else {
                var n = Ares.today(),
                    t = moment(n).startOf("month").format("YYYY-MM-DD"),
                    r = moment(n).startOf("month").add(1, "month").add(-1, "days").format("YYYY-MM-DD");
                i.timeSpan = {
                    startDate: t,
                    endDate: r
                }
            }
        })
    })()
}]);
scheduleRuleModule.controller("SchedulerProviderCtrl", ["$log", "$scope", "$timeout", "$q", "scheduleSvc", "loginContext", "dataDicSvc", "apptUtil", "aresDialog", "schedulerUtil", function(n, t, i, r, u, f, e, o, s, h) {
    "use strict";
    var w = function() {
            u.getAllActiveRule().success(function(n) {
                for (var i = 0; i < n.length; ++i) n[i].startTimeStr = moment("2016-01-01 " + n[i].startTime).format("HH:mm"), n[i].endTimeStr = moment("2016-01-01 " + n[i].endTime).format("HH:mm"), n[i].isOnDutyStr = n[i].isOnDuty ? "可约诊" : "不可约诊";
                t.scheduleRules = n
            }).error(function(t) {
                n.log(t);
                s.info("信息", "班次获取失败!")
            })
        },
        a = function() {
            var i = t.isDoctorMode ? "医生" : "不包含医生";
            u.getProviderScheduleTemplates(t.officeId, i).success(function(n) {
                t.schedules = n;
                y(n)
            }).error(function(t) {
                n.log(t);
                s.info("信息", "数据加载错误!")
            })
        },
        c = function() {
            var n = {
                startDate: moment(t.range.start).format("YYYY-MM-DD"),
                endDate: moment(t.range.end).format("YYYY-MM-DD"),
                officeId: t.officeId,
                jobType: t.isDoctorMode ? "医生" : "不包含医生"
            };
            u.getLiteSchedules(n).then(function(n) {
                t.schedules = n;
                y(n)
            })
        },
        y = function(n) {
            var u = moment(Ares.today()).format("YYYY-MM-DD"),
                r;
            angular.forEach(n, function(n) {
                var t = _.filter(n.schedules, function(n) {
                    return d(n.date, u)
                });
                t && angular.forEach(t, function(n) {
                    n.schedules[0].isDisable = !0
                })
            });
            r = [];
            r.push(f.officeId);
            angular.forEach(n, function(n) {
                r.indexOf(n.provider.officeId) == -1 && r.push(n.provider.officeId)
            });
            e.officeDic.load().then(function(u) {
                var e = [],
                    f;
                angular.forEach(r, function(n) {
                    var t = _.find(u, function(t) {
                        return t.id == n
                    });
                    t && e.push(t)
                });
                f = [];
                angular.forEach(e, function(i) {
                    var e = {},
                        r, o;
                    e.office = i;
                    r = _.filter(n, function(n) {
                        return n.provider.officeId == i.id
                    });
                    angular.forEach(r, function(n) {
                        var r = _.find(u, function(t) {
                                return n.provider.officeId == t.id
                            }),
                            i;
                        n.provider.officeName = r.name;
                        i = _.find(t.sortDoctors, function(t) {
                            return t.id == n.provider.id
                        });
                        n.showOrder = i ? i.showOrder : 999
                    });
                    r = _.sortBy(r, "showOrder");
                    o = _.groupBy(r, function(n) {
                        return n.provider.job
                    });
                    e.doctorSchedules = r;
                    e.groupSchedule = o;
                    f.push(e)
                });
                t.initialize && (t.offices = e, t.initialize = !1);
                t.officeSchedules = f;
                t.allOfficeSchedules = t.officeId ? null : _.clone(f);
                i(function() {
                    t.initTableView()
                })
            })
        },
        b = function(n) {
            t.selectedTemplate = n;
            t.schedulingChange(n);
            v();
            t.removeViewBtnsClass();
            t.selectedTemplate ? (t.selectedRule = null, a()) : (t.date = Ares.today(), t.selectedRule = null, l(), c());
            t.initDropdown()
        },
        l = function() {
            t.range = o.getDateRange(t.date, "w");
            t.range.monday = moment(t.range.start).format("YYYY-MM-DD");
            t.range.tuesday = moment(t.range.start).add(1, "d").format("YYYY-MM-DD");
            t.range.wednesday = moment(t.range.start).add(2, "d").format("YYYY-MM-DD");
            t.range.thursday = moment(t.range.start).add(3, "d").format("YYYY-MM-DD");
            t.range.friday = moment(t.range.start).add(4, "d").format("YYYY-MM-DD");
            t.range.saturday = moment(t.range.start).add(5, "d").format("YYYY-MM-DD");
            t.range.sunday = moment(t.range.start).add(6, "d").format("YYYY-MM-DD")
        },
        k = function(n) {
            t.date = moment(t.date).add(n, "d");
            l();
            c();
            v()
        },
        v = function() {
            angular.forEach(t.selectedSchedules, function(n) {
                n.isSelected = !1;
                n.isShowDelBtn = !1
            });
            t.selectedSchedules = []
        },
        d = function(n, t) {
            n = moment(n).format("YYYY-MM-DD");
            var i = moment(n),
                r = moment(t);
            return i >= r ? !1 : !0
        },
        p = function() {
            h.loadSortedDoctors().then(function(n) {
                t.sortDoctors = n;
                t.selectedTemplate ? a() : (l(), c())
            })
        },
        g = function(n) {
            t.workerChange(n);
            t.isDoctorMode != n && (t.isDoctorMode = n, t.selectedTemplate ? a() : c())
        };
    (function() {
        t.initialize = !0;
        t.selectedSchedules = [];
        t.date = Ares.today();
        t.selectedRule = null;
        t.officeId = null;
        t.selectedTemplate = !1;
        t.isDoctorMode = !0;
        t.changeWeek = k;
        t.setScheduleType = b;
        t.getDateRange = l;
        t.init = p;
        t.initDoctorSchedule = c;
        t.clearSelectedSchedule = v;
        t.currentOfficeId = f.officeId;
        t.toggleMode = g;
        w();
        p()
    })()
}]);
scheduleRuleModule.controller("SchedulerTenantListCtrl", ["$log", "$scope", "$q", "$timeout", "scheduleSvc", "loginContext", "dataDicSvc", "apptUtil", function(n, t, i, r, u, f, e, o) {
    "use strict";
    var s = function() {
            var n = {
                officeId: t.officeId,
                startDate: moment(t.range.start).format("YYYY-MM-DD"),
                endDate: moment(t.range.end).format("YYYY-MM-DD"),
                jobType: t.isDoctorMode ? "医生" : "不包含医生"
            };
            u.getOnDutyLiteSchedules(n).then(function(n) {
                t.schedules = n;
                c(n)
            })
        },
        c = function(n) {
            var i = [];
            i.push(t.officeId);
            e.officeDic.load().then(function(u) {
                var f, e;
                t.offices = u;
                f = [];
                angular.forEach(i, function(n) {
                    var t = _.find(u, function(t) {
                        return t.id == n
                    });
                    t && f.push(t)
                });
                e = [];
                angular.forEach(f, function(t) {
                    var i = {},
                        r, f;
                    i.office = t;
                    r = _.filter(n, function(n) {
                        return n.provider.officeId == t.id
                    });
                    angular.forEach(r, function(n) {
                        var t = _.find(u, function(t) {
                            return n.provider.officeId == t.id
                        });
                        n.provider.officeName = t.name
                    });
                    f = _.groupBy(r, function(n) {
                        return n.provider.job
                    });
                    i.groupSchedule = f;
                    i.doctorSchedules = r;
                    e.push(i)
                });
                t.officeSchedules = e;
                r(function() {
                    t.initTableView()
                })
            })
        },
        h = function() {
            t.range = o.getDateRange(t.date, "w");
            t.range.monday = moment(t.range.start).format("YYYY-MM-DD");
            t.range.tuesday = moment(t.range.start).add(1, "d").format("YYYY-MM-DD");
            t.range.wednesday = moment(t.range.start).add(2, "d").format("YYYY-MM-DD");
            t.range.thursday = moment(t.range.start).add(3, "d").format("YYYY-MM-DD");
            t.range.friday = moment(t.range.start).add(4, "d").format("YYYY-MM-DD");
            t.range.saturday = moment(t.range.start).add(5, "d").format("YYYY-MM-DD");
            t.range.sunday = moment(t.range.start).add(6, "d").format("YYYY-MM-DD")
        },
        l = function(n) {
            t.date = moment(t.date).add(n, "d");
            h();
            s()
        },
        a = function() {
            angular.forEach(t.selectedSchedules, function(n) {
                n.isSelected = !1
            });
            t.selectedSchedules = []
        },
        v = function(n) {
            t.workerChange(n);
            t.isDoctorMode = n;
            s()
        };
    (function() {
        t.selectedSchedules = [];
        t.date = Ares.today();
        t.isTenantReport = !0;
        t.isDoctorMode = !0;
        t.changeWeek = l;
        t.getDateRange = h;
        t.officeId = f.officeId;
        t.clearSelectedSchedule = a;
        t.initDoctorSchedule = s;
        t.toggleMode = v;
        h();
        s()
    })()
}]);
scheduleRuleModule.directive("scheduleSelectHost", ["$log", "scheduleSvc", "loginContext", "aresNotification", "aresDialog", function(n, t, i, r, u) {
    return {
        restrict: "A",
        scope: !0,
        link: function(n) {
            var e = function(t, i) {
                    var r = t.isSelected;
                    i || n.clearSelectedSchedule();
                    r || (t.isSelected = t.isSelected == undefined || t.isSelected == !1 ? !0 : !1, n.isTenantReport || (t.isShowDelBtn = t.isShowDelBtn == undefined || t.isShowDelBtn == !1 ? !0 : !1), n.selectedSchedules.push(t))
                },
                s = function(t) {
                    n.isTenantReport || Ares.ensureNotDuplicated("OnScheduleSaved") && (n.clearSelectedSchedule(), n.selectedTemplate ? (w(t), e(t.monday.schedules[0], !0), e(t.tuesday.schedules[0], !0), e(t.wednesday.schedules[0], !0), e(t.thursday.schedules[0], !0), e(t.friday.schedules[0], !0), e(t.saturday.schedules[0], !0), e(t.sunday.schedules[0], !0), n.selectedRule && v(t)) : c(t))
                },
                h = function(u, o) {
                    if (!n.isTenantReport && Ares.ensureNotDuplicated("OnScheduleSaved")) {
                        n.clearSelectedSchedule();
                        var s = [];
                        angular.forEach(u, function(t) {
                            angular.forEach(t.doctorSchedules, function(t) {
                                var i = _.find(t, function(n) {
                                        return n.dayOfWeek == o
                                    }),
                                    r;
                                i.schedules[0].dayOfWeek = i.dayOfWeek;
                                e(i.schedules[0], !0);
                                n.selectedRule && (r = f(i.dayOfWeek, i.schedules[0]), s.push(r))
                            })
                        });
                        n.selectedRule && t.setScheduleTemplateList(s).success(function() {
                            r.success("操作成功!");
                            angular.forEach(u, function(t) {
                                angular.forEach(t.doctorSchedules, function(t) {
                                    var r = _.find(t, function(n) {
                                        return n.dayOfWeek == o
                                    });
                                    r.schedules[0].color = r.schedules[0].newColor;
                                    r.schedules[0].ruleName = n.selectedRule.name;
                                    r.schedules[0].officeId = i.officeId
                                })
                            })
                        })
                    }
                },
                c = function(t) {
                    if (!n.isTenantReport) {
                        var i = 0;
                        angular.forEach(t.schedules, function(n) {
                            n.schedules[0].isDisable ? i++ : (n.schedules[0].date = n.date, e(n.schedules[0], !0))
                        });
                        n.selectedRule && i != 7 && y(t)
                    }
                },
                l = function(n) {
                    switch (n) {
                        case 0:
                            return "sunday";
                        case 1:
                            return "monday";
                        case 2:
                            return "tuesday";
                        case 3:
                            return "wednesday";
                        case 4:
                            return "thursday";
                        case 5:
                            return "friday";
                        case 6:
                            return "saturday"
                    }
                },
                a = function(u) {
                    var o, h, s;
                    n.isTenantReport || (n.clearSelectedSchedule(), o = [], n.selectedTemplate ? n.selectedRule && (h = new Date(u).getDay(), s = l(h), angular.forEach(n.schedules, function(n) {
                        e(n[s].schedules[0], !0);
                        var t = f(h, n[s].schedules[0]);
                        o.push(t)
                    }), o.length > 0 && t.setScheduleTemplateList(o).success(function() {
                        r.success("操作成功!");
                        angular.forEach(n.schedules, function(t) {
                            t[s].schedules[0].color = t[s].schedules[0].newColor;
                            t[s].schedules[0].ruleName = n.selectedRule.name;
                            t[s].schedules[0].officeId = i.officeId;
                            var r = f(h, t[s].schedules[0]);
                            o.push(r)
                        })
                    })) : (angular.forEach(n.schedules, function(t) {
                        angular.forEach(t.schedules, function(t) {
                            var i = moment(t.date).format("YYYY-MM-DD"),
                                r;
                            i != u || t.schedules[0].isDisable || (t.schedules[0].date = i, n.selectedRule && (e(t.schedules[0], !0), r = f(1, t.schedules[0], t.date), o.push(r)))
                        })
                    }), n.selectedRule && o.length > 0 && t.setScheduleList(o).success(function() {
                        r.success("操作成功!");
                        angular.forEach(n.schedules, function(t) {
                            angular.forEach(t.schedules, function(t) {
                                var r = moment(t.date).format("YYYY-MM-DD");
                                r != u || t.schedules[0].isDisable || (t.schedules[0].color = t.schedules[0].newColor, t.schedules[0].ruleName = n.selectedRule.name, t.schedules[0].officeId = i.officeId)
                            })
                        })
                    })))
                },
                v = function(u) {
                    var e = [],
                        v = f(u.monday.dayOfWeek, u.monday.schedules[0]),
                        o, s, h, c, l, a;
                    e.push(v);
                    o = f(u.tuesday.dayOfWeek, u.tuesday.schedules[0]);
                    e.push(o);
                    s = f(u.wednesday.dayOfWeek, u.wednesday.schedules[0]);
                    e.push(s);
                    h = f(u.thursday.dayOfWeek, u.thursday.schedules[0]);
                    e.push(h);
                    c = f(u.friday.dayOfWeek, u.friday.schedules[0]);
                    e.push(c);
                    l = f(u.saturday.dayOfWeek, u.saturday.schedules[0]);
                    e.push(l);
                    a = f(u.sunday.dayOfWeek, u.sunday.schedules[0]);
                    e.push(a);
                    t.setScheduleTemplateList(e).success(function() {
                        r.success("操作成功!");
                        u.monday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.monday.schedules[0].ruleName = n.selectedRule.name;
                        u.monday.schedules[0].officeId = i.officeId;
                        u.tuesday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.tuesday.schedules[0].ruleName = n.selectedRule.name;
                        u.tuesday.schedules[0].officeId = i.officeId;
                        u.wednesday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.wednesday.schedules[0].ruleName = n.selectedRule.name;
                        u.wednesday.schedules[0].officeId = i.officeId;
                        u.thursday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.thursday.schedules[0].ruleName = n.selectedRule.name;
                        u.thursday.schedules[0].officeId = i.officeId;
                        u.friday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.friday.schedules[0].ruleName = n.selectedRule.name;
                        u.friday.schedules[0].officeId = i.officeId;
                        u.saturday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.saturday.schedules[0].ruleName = n.selectedRule.name;
                        u.saturday.schedules[0].officeId = i.officeId;
                        u.sunday.schedules[0].color = u.monday.schedules[0].newColor;
                        u.sunday.schedules[0].ruleName = n.selectedRule.name;
                        u.sunday.schedules[0].officeId = i.officeId
                    })
                },
                y = function(u) {
                    var e = [],
                        o, s, h, c, l, a, v;
                    u.schedules[0].schedules[0].isDisable || (o = f(null, u.schedules[0].schedules[0], u.schedules[0].date), e.push(o));
                    u.schedules[1].schedules[0].isDisable || (s = f(null, u.schedules[1].schedules[0], u.schedules[1].date), e.push(s));
                    u.schedules[2].schedules[0].isDisable || (h = f(null, u.schedules[2].schedules[0], u.schedules[2].date), e.push(h));
                    u.schedules[3].schedules[0].isDisable || (c = f(null, u.schedules[3].schedules[0], u.schedules[3].date), e.push(c));
                    u.schedules[4].schedules[0].isDisable || (l = f(null, u.schedules[4].schedules[0], u.schedules[4].date), e.push(l));
                    u.schedules[5].schedules[0].isDisable || (a = f(null, u.schedules[5].schedules[0], u.schedules[5].date), e.push(a));
                    u.schedules[6].schedules[0].isDisable || (v = f(null, u.schedules[6].schedules[0], u.schedules[6].date), e.push(v));
                    t.setScheduleList(e).success(function() {
                        r.success("操作成功!");
                        u.schedules[0].schedules[0].isDisable || (u.schedules[0].schedules[0].color = u.schedules[0].schedules[0].newColor, u.schedules[0].schedules[0].ruleName = n.selectedRule.name, u.schedules[0].schedules[0].officeId = i.officeId);
                        u.schedules[1].schedules[0].isDisable || (u.schedules[1].schedules[0].color = u.schedules[1].schedules[0].newColor, u.schedules[1].schedules[0].ruleName = n.selectedRule.name, u.schedules[1].schedules[0].officeId = i.officeId);
                        u.schedules[2].schedules[0].isDisable || (u.schedules[2].schedules[0].color = u.schedules[2].schedules[0].newColor, u.schedules[2].schedules[0].ruleName = n.selectedRule.name, u.schedules[2].schedules[0].officeId = i.officeId);
                        u.schedules[3].schedules[0].isDisable || (u.schedules[3].schedules[0].color = u.schedules[3].schedules[0].newColor, u.schedules[3].schedules[0].ruleName = n.selectedRule.name, u.schedules[3].schedules[0].officeId = i.officeId);
                        u.schedules[4].schedules[0].isDisable || (u.schedules[4].schedules[0].color = u.schedules[4].schedules[0].newColor, u.schedules[4].schedules[0].ruleName = n.selectedRule.name, u.schedules[4].schedules[0].officeId = i.officeId);
                        u.schedules[5].schedules[0].isDisable || (u.schedules[5].schedules[0].color = u.schedules[5].schedules[0].newColor, u.schedules[5].schedules[0].ruleName = n.selectedRule.name, u.schedules[5].schedules[0].officeId = i.officeId);
                        u.schedules[6].schedules[0].isDisable || (u.schedules[6].schedules[0].color = u.schedules[6].schedules[0].newColor, u.schedules[6].schedules[0].ruleName = n.selectedRule.name, u.schedules[6].schedules[0].officeId = i.officeId)
                    })
                },
                f = function(t, i, r) {
                    var u = "transparent",
                        e = null,
                        o = null,
                        f;
                    return n.selectedRule.name == "正常班" ? (u = "transparent", e = !0) : n.selectedRule.name == "休息" ? (u = "#a9a9a9", e = !1) : (u = n.selectedRule.color, o = n.selectedRule.id), f = {
                        providerId: i.providerId,
                        isOnDuty: e,
                        ruleId: o
                    }, n.selectedTemplate ? f.dayOfWeek = t : f.date = moment(r).format("YYYY-MM-DD"), i.newColor = u, f
                },
                p = function() {
                    var f, i, e;
                    n.selectedSchedules.length > 0 ? (f = _.filter(n.selectedSchedules, function(n) {
                        return n.isSelected == !0
                    }), f && f.length == 1 ? (i = {
                        providerId: f[0].providerId
                    }, n.selectedTemplate ? (i.dayOfWeek = f[0].dayOfWeek * 1, t.removeScheduleTemplate(i).success(function(n) {
                        o(i.dayOfWeek, i.providerId, n.schedules[0]);
                        r.success("操作成功!")
                    })) : (i.date = moment(f[0].date).format("YYYY-MM-DD"), t.removeSchedule(i).success(function(n) {
                        o(null, i.providerId, n.schedules[0], i.date);
                        r.success("操作成功!")
                    }))) : n.selectedTemplate ? (e = [], angular.forEach(f, function(n) {
                        var t = {
                            dayOfWeek: n.dayOfWeek * 1,
                            providerId: n.providerId
                        };
                        e.push(t)
                    }), t.removeScheduleTemplateList(e).success(function(n) {
                        angular.forEach(n, function(n) {
                            o(n.dayOfWeek, n.schedules[0].providerId, n.schedules[0])
                        });
                        r.success("操作成功!")
                    })) : (e = [], angular.forEach(f, function(n) {
                        var t = {
                            date: moment(n.date).format("YYYY-MM-DD"),
                            providerId: n.providerId
                        };
                        e.push(t)
                    }), t.removeScheduleList(e).success(function(n) {
                        angular.forEach(n, function(n) {
                            o(null, n.schedules[0].providerId, n.schedules[0], n.date)
                        });
                        r.success("操作成功!")
                    }))) : u.info("提示", "请选择已排班次!")
                },
                w = function(n) {
                    n.monday.schedules[0].dayOfWeek = n.monday.dayOfWeek;
                    n.tuesday.schedules[0].dayOfWeek = n.tuesday.dayOfWeek;
                    n.wednesday.schedules[0].dayOfWeek = n.wednesday.dayOfWeek;
                    n.thursday.schedules[0].dayOfWeek = n.thursday.dayOfWeek;
                    n.friday.schedules[0].dayOfWeek = n.friday.dayOfWeek;
                    n.saturday.schedules[0].dayOfWeek = n.saturday.dayOfWeek;
                    n.sunday.schedules[0].dayOfWeek = n.sunday.dayOfWeek
                },
                o = function(t, i, r, u) {
                    var f = _.find(n.schedules, function(n) {
                        return n.provider.id == i
                    });
                    if (n.selectedTemplate) switch (t) {
                        case 0:
                            f.sunday.schedules[0] = r;
                            break;
                        case 1:
                            f.monday.schedules[0] = r;
                            break;
                        case 2:
                            f.tuesday.schedules[0] = r;
                            break;
                        case 3:
                            f.wednesday.schedules[0] = r;
                            break;
                        case 4:
                            f.thursday.schedules[0] = r;
                            break;
                        case 5:
                            f.friday.schedules[0] = r;
                            break;
                        case 6:
                            f.saturday.schedules[0] = r
                    } else {
                        u = moment(u).format("YYYY-MM-DD");
                        switch (u) {
                            case n.range.sunday:
                                f.schedules[6].schedules[0] = r;
                                break;
                            case n.range.monday:
                                f.schedules[0].schedules[0] = r;
                                break;
                            case n.range.tuesday:
                                f.schedules[1].schedules[0] = r;
                                break;
                            case n.range.wednesday:
                                f.schedules[2].schedules[0] = r;
                                break;
                            case n.range.thursday:
                                f.schedules[3].schedules[0] = r;
                                break;
                            case n.range.friday:
                                f.schedules[4].schedules[0] = r;
                                break;
                            case n.range.saturday:
                                f.schedules[5].schedules[0] = r
                        }
                    }
                };
            (function() {
                n.selectSchedule = e;
                n.selectRow = s;
                n.selectCell = h;
                n.selectAllCell = a;
                n.removeSchedule = p
            })()
        }
    }
}]);
patientModule.directive("scheduleAttendanceConfigView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", "mapUtil", function() {
    "use strict";
    return {
        restrict: "E",
        replace: !0,
        controller: "ScheduleAttendanceConfigCtrl",
        templateUrl: "/app/schedule-rule/views/schedule-attendance-config-view.html",
        scope: {
            job: "@"
        },
        link: function(n) {
            (function() {
                n.defaultClass = "label-show";
                n.defaultHideClass = "label-hide"
            })()
        }
    }
}]);
patientModule.directive("scheduleAttendanceDayListView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", function(n, t, i, r, u, f, e) {
    "use strict";
    return {
        restrict: "E",
        replace: !0,
        controller: "ScheduleAttendanceDayListCtrl",
        templateUrl: "/app/schedule-rule/views/schedule-attendance-day-list-view.html",
        scope: {
            job: "@"
        },
        link: function(n, t) {
            var i = !0,
                r = function() {
                    var i = $(window).height() - 170 - (window.Ares3 ? 20 : 0);
                    t.find("#scheduleAttendanceReportList").html("");
                    t.find("#scheduleAttendanceReportList").kendoGrid({
                        dataSource: {
                            data: n.dataSource,
                            aggregate: n.aggregate
                        },
                        scrollable: !0,
                        height: i,
                        sortable: !0,
                        selectable: "single",
                        model: {
                            id: "id"
                        },
                        columns: n.gridColumns
                    }).data("kendoGrid")
                },
                u = function() {
                    var i = t.find("#scheduleAttendanceReportList").data("kendoGrid");
                    i && n.dataSource.length > 0 && i.saveAsExcel()
                },
                f = function() {
                    t.find("#provider").kendoMultiSelect({
                        placeholder: "全部",
                        dataTextField: "name",
                        dataValueField: "id",
                        dataSource: n.providers
                    })
                },
                o = function() {
                    var n = t.find("#provider").data("kendoMultiSelect");
                    return n ? n.value().length > 0 ? n.value().join() : "-1" : "-1"
                },
                s = function() {
                    e.getOtherProvider().success(function(t) {
                        t.length > 0 && (n.providers = t)
                    })
                };
            (function() {
                s();
                n.exportExcel = u;
                n.getProviders = o;
                n.isAres3 = window.Ares3;
                n.$watch("dataSource", function() {
                    n.dataSource && n.dataSource.length > 0 && (t.find("#scheduleAttendanceReportList").show(), r());
                    n.dataSource && n.dataSource.length <= 0 && t.find("#scheduleAttendanceReportList").hide()
                });
                n.$watch("providers", function() {
                    n.providers && n.providers.length > 0 && i && (i = !1, f())
                })
            })()
        }
    }
}]);
patientModule.directive("scheduleAttendanceListView", ["$log", "$timeout", "$filter", "$window", "appNav", "dataDicSvc", "providerSvc", function(n, t, i, r, u, f, e) {
    "use strict";
    return {
        restrict: "E",
        replace: !0,
        controller: "ScheduleAttendanceListCtrl",
        templateUrl: "/app/schedule-rule/views/schedule-attendance-list-view.html",
        scope: {
            job: "@"
        },
        link: function(n, t) {
            var i = !0,
                r = function() {
                    var i = $(window).height() - 170 - (window.Ares3 ? 20 : 0);
                    t.find("#scheduleAttendanceReportList").html("");
                    t.find("#scheduleAttendanceReportList").kendoGrid({
                        dataSource: {
                            data: n.dataSource,
                            aggregate: n.aggregate
                        },
                        scrollable: !0,
                        height: i,
                        sortable: !0,
                        selectable: "single",
                        model: {
                            id: "id"
                        },
                        columns: n.gridColumns
                    }).data("kendoGrid")
                },
                u = function() {
                    var i = t.find("#scheduleAttendanceReportList").data("kendoGrid");
                    i && n.dataSource.length > 0 && i.saveAsExcel()
                },
                f = function() {
                    t.find("#provider").kendoMultiSelect({
                        placeholder: "全部",
                        dataTextField: "name",
                        dataValueField: "id",
                        dataSource: n.providers
                    })
                },
                o = function() {
                    var n = t.find("#provider").data("kendoMultiSelect");
                    return n ? n.value().length > 0 ? n.value().join() : "-1" : "-1"
                },
                s = function() {
                    e.getOtherProvider().success(function(t) {
                        t.length > 0 && (n.providers = t)
                    })
                };
            (function() {
                s();
                n.exportExcel = u;
                n.getProviders = o;
                n.isAres3 = window.Ares3;
                n.$watch("dataSource", function() {
                    n.dataSource && n.dataSource.length > 0 && (t.find("#scheduleAttendanceReportList").show(), r());
                    n.dataSource && n.dataSource.length <= 0 && t.find("#scheduleAttendanceReportList").hide()
                });
                n.$watch("providers", function() {
                    n.providers && n.providers.length > 0 && i && (i = !1, f())
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleCell", ["$log", "$filter", "scheduleSvc", "loginContext", "aresNotification", function(n, t, i, r, u) {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-cell.html",
        scope: {
            dayOfWeek: "@",
            schedule: "=",
            selectSchedule: "=",
            selectedRule: "=",
            selectedTemplate: "=",
            date: "="
        },
        link: function(n) {
            var t = function(t) {
                    var e, r;
                    if (Ares.ensureNotDuplicated("SaveSchedule") && !n.schedule.isDisable && (n.schedule.dayOfWeek = n.dayOfWeek, n.schedule.date = n.date, n.selectSchedule(n.schedule), e = $(t.target).parent(".del-btn"), n.selectedRule && e.length == 0)) {
                        var i = "transparent",
                            u = null,
                            o = null;
                        n.selectedRule.name == "正常班" ? (i = "transparent", u = !0) : n.selectedRule.name == "休息" ? (i = "#a9a9a9", u = !1) : (i = n.selectedRule.color, o = n.selectedRule.id);
                        r = {
                            providerId: n.schedule.providerId,
                            isOnDuty: u,
                            ruleId: o
                        };
                        n.selectedTemplate ? r.dayOfWeek = n.dayOfWeek : r.date = moment(n.date).format("YYYY-MM-DD");
                        f(r, i)
                    }
                },
                f = function(t, r) {
                    n.selectedTemplate ? i.setScheduleTemplate(t).success(function() {
                        u.success("操作成功!");
                        n.schedule.color = r;
                        n.schedule.ruleName = n.selectedRule.name;
                        n.schedule.officeId = n.currentOfficeId
                    }) : i.setSchedule(t).success(function() {
                        u.success("操作成功!");
                        n.schedule.color = r;
                        n.schedule.ruleName = n.selectedRule.name;
                        n.schedule.officeId = n.currentOfficeId
                    })
                },
                e = function() {
                    if (n.schedule.officeId == n.currentOfficeId) {
                        var t = {
                            providerId: n.schedule.providerId
                        };
                        n.selectedTemplate ? (t.dayOfWeek = n.dayOfWeek * 1, i.removeScheduleTemplate(t).success(function(t) {
                            n.schedule = t.schedules[0];
                            u.success("操作成功!")
                        })) : (t.date = moment(n.date).format("YYYY-MM-DD"), i.removeSchedule(t).success(function(t) {
                            n.schedule = t.schedules[0];
                            u.success("操作成功!")
                        }))
                    }
                };
            (function() {
                n.currentOfficeId = r.officeId;
                n.select = t;
                n.remove = e
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleContentView", ["$log", "$modal", "$q", "$window", "$timeout", "scheduleSvc", "aresDialog", function() {
    return {
        restrict: "E",
        templateUrl: function(n, t) {
            return t.isDoctorMode == "true" ? "/app/schedule-rule/views/schedule-content-doctor-view.html" : "/app/schedule-rule/views/schedule-content-view.html"
        },
        scope: {
            officeSchedule: "=",
            selectedRule: "=",
            selectSchedule: "=",
            selectRow: "=",
            selectedTemplate: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleProviderContentDoctorTemplateView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-provider-content-doctor-template-view.html",
        scope: {
            officeSchedule: "=",
            selectedRule: "=",
            selectSchedule: "=",
            selectRow: "=",
            selectedTemplate: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleProviderContentDoctorView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-provider-content-doctor-view.html",
        scope: {
            officeSchedule: "=",
            selectedRule: "=",
            selectSchedule: "=",
            selectRow: "=",
            selectedTemplate: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleProviderContentPersonnelTemplateView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-provider-content-personnel-template-view.html",
        scope: {
            officeSchedule: "=",
            selectedRule: "=",
            selectSchedule: "=",
            selectRow: "=",
            selectedTemplate: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleProviderContentPersonnelView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-provider-content-personnel-view.html",
        scope: {
            officeSchedule: "=",
            selectedRule: "=",
            selectSchedule: "=",
            selectRow: "=",
            selectedTemplate: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleProviderView", ["$log", "$modal", "$q", "$window", "$timeout", "scheduleSvc", "aresDialog", "aresNotification", "officeSvc", function(n, t, i, r, u, f, e, o) {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-provider-view.html",
        controller: "SchedulerProviderCtrl",
        link: function(n, t) {
            var u = {
                    scrollButtons: {
                        enable: !1
                    },
                    autoHideScrollbar: !0,
                    scrollInertia: 150,
                    advanced: {
                        updateOnContentResize: !0
                    }
                },
                l = function() {
                    i();
                    var n = angular.element(r);
                    t.find(".provider-content").mCustomScrollbar(u);
                    n.on("resize", function() {
                        i()
                    })
                },
                i = function() {
                    var i = angular.element(r).height(),
                        f = i - 295 - (window.Ares3 ? 20 : 0),
                        n = t.find(".provider-content");
                    n.height(f);
                    n.data("mCustomScrollbarIndex") ? n.mCustomScrollbar("update") : n.mCustomScrollbar(u)
                },
                e = function() {
                    t.find(".schedule-view-btns").children("button").removeClass("btn-primary")
                },
                a = function(i) {
                    n.selectedRule ? n.selectedRule.name == i.name ? n.selectedRule = null : (n.selectedRule = i, s()) : (n.selectedRule = i, s());
                    var r = t.find(".schedule-view-btns");
                    e();
                    i.name == "正常班" ? r.children(".v-normal").addClass("btn-primary") : i.name == "休息" ? r.children(".v-rest").addClass("btn-primary") : r.children("." + i.id + "").addClass("btn-primary")
                },
                s = function() {
                    var r;
                    if (n.selectedSchedules.length == 1) {
                        var t = n.selectedSchedules[0],
                            i = "transparent",
                            u = null,
                            f = null;
                        n.selectedRule.name == "正常班" ? (i = "transparent", u = !0) : n.selectedRule.name == "休息" ? (i = "#a9a9a9", u = !1) : (i = n.selectedRule.color, f = n.selectedRule.id);
                        r = {
                            providerId: t.providerId,
                            isOnDuty: u,
                            ruleId: f
                        };
                        n.selectedTemplate ? (r.dayOfWeek = t.dayOfWeek, p(t, r, i)) : (r.date = moment(t.date).format("YYYY-MM-DD"), y(t, r, i))
                    }
                    n.selectedSchedules.length > 1 && v()
                },
                v = function() {
                    var i = "transparent",
                        r = null,
                        u = null,
                        t;
                    n.selectedRule.name == "正常班" ? (i = "transparent", r = !0) : n.selectedRule.name == "休息" ? (i = "#a9a9a9", r = !1) : (i = n.selectedRule.color, u = n.selectedRule.id);
                    t = [];
                    angular.forEach(n.selectedSchedules, function(i) {
                        var f = {
                            providerId: i.providerId,
                            isOnDuty: r,
                            ruleId: u
                        };
                        n.selectedTemplate ? f.dayOfWeek = i.dayOfWeek : f.date = moment(i.date).format("YYYY-MM-DD");
                        t.push(f)
                    });
                    t.length > 0 && (n.selectedTemplate ? b(t) : w(t))
                },
                y = function(t, i, r) {
                    f.setSchedule(i).success(function() {
                        o.success("操作成功!");
                        t.color = r;
                        t.ruleName = n.selectedRule.name;
                        t.officeId = n.currentOfficeId
                    })
                },
                p = function(t, i, r) {
                    n.selectedTemplate && f.setScheduleTemplate(i).success(function() {
                        o.success("操作成功!");
                        t.color = r;
                        t.ruleName = n.selectedRule.name;
                        t.officeId = n.currentOfficeId
                    })
                },
                w = function(n) {
                    f.setScheduleList(n).success(function(n) {
                        h(n);
                        o.success("操作成功!")
                    })
                },
                b = function(n) {
                    f.setScheduleTemplateList(n).success(function(n) {
                        h(n);
                        o.success("操作成功!")
                    })
                },
                h = function(t) {
                    n.selectedTemplate ? angular.forEach(t, function(t) {
                        var r = t.dayOfWeek,
                            i = _.find(n.selectedSchedules, function(n) {
                                return n.providerId == t.schedules[0].providerId && n.dayOfWeek == r
                            });
                        i && _.extend(i, t.schedules[0])
                    }) : angular.forEach(t, function(t) {
                        var r = moment(t.date).format("YYYY-MM-DD"),
                            i = _.find(n.selectedSchedules, function(n) {
                                var i = moment(n.date).format("YYYY-MM-DD");
                                return n.providerId == t.schedules[0].providerId && i == r
                            });
                        i && _.extend(i, t.schedules[0])
                    })
                },
                c = function() {
                    t.find("#officeInput").kendoDropDownList({
                        dataTextField: "name",
                        dataValueField: "id",
                        optionLabel: "全部诊所",
                        select: function(t) {
                            var i = this;
                            n.officeId = i.dataItem(t.item)[i.options.dataValueField] || null;
                            n.init()
                        },
                        dataSource: n.offices
                    })
                },
                k = function() {
                    var n = t.find("#officeInput").data("kendoDropDownList");
                    n || c()
                },
                d = function(t) {
                    n.date = t;
                    n.getDateRange();
                    n.initDoctorSchedule();
                    n.clearSelectedSchedule()
                },
                g = function(n) {
                    var r = t.find(".worker-btns"),
                        i = "";
                    i = n ? "btn-doctor" : "btn-worker";
                    r.children("." + i + "").addClass("btn-primary").siblings("button").removeClass("btn-primary")
                },
                nt = function(n) {
                    var r = t.find(".template-btns"),
                        i = "";
                    n ? (i = "fixed-scheduling", t.find(".weekly-shif-row").hide()) : (i = "weekly-shif", t.find(".weekly-shif-row").show());
                    r.children("." + i + "").addClass("btn-primary").siblings("button").removeClass("btn-primary")
                };
            (function() {
                l();
                n.initTableView = i;
                n.initDropdown = k;
                n.onSelectRule = a;
                n.searchByDate = d;
                n.removeViewBtnsClass = e;
                n.workerChange = g;
                n.schedulingChange = nt;
                n.$watch("offices", function() {
                    n.offices && c()
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleRuleView", ["$log", "$modal", "$q", "$window", "$timeout", "scheduleSvc", "aresDialog", "appNav", "officeSvc", "aresModalShelf", function(n, t, i, r, u, f, e, o, s, h) {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-rule-view.html",
        link: function(n, t) {
            var l = !1;
            n.isShowColor = !0;
            n.allowClick = !0;
            r.showColor = function(t) {
                if (n.allowClick) {
                    var i = $(t).find("#colorPicker").data("kendoColorPicker");
                    n.isShowColor ? (i.open(), n.isShowColor = !1) : (i.close(), n.isShowColor = !0)
                }
            };
            var y = function(n) {
                    if (window.Ares3) {
                        var t = h.open({
                            title: "诊所信息编辑",
                            template: "<ares3-office-edit-page><\/ares3-office-edit-page>",
                            controller: "Ares3OfficeEditCtrl",
                            needActive: !0
                        });
                        t.result.then(function() {
                            a()
                        })
                    } else o.switchState(n)
                },
                a = function() {
                    var t = i.defer();
                    return s.getOfficeSchedule().success(function(i) {
                        n.officeSchedule = i;
                        n.officeSchedule.openTimeStr = moment("2016-01-01 " + n.officeSchedule.openTime).format("HH:mm");
                        n.officeSchedule.closeTimeStr = moment("2016-01-01 " + n.officeSchedule.closeTime).format("HH:mm");
                        n.defaultRule = [{
                            name: "正常班",
                            color: "#fff",
                            startTimeStr: n.officeSchedule.openTimeStr,
                            endTimeStr: n.officeSchedule.closeTimeStr,
                            isOnDutyStr: "可约诊",
                            isDefault: !0
                        }, {
                            name: "休息",
                            color: "#a9a9a9",
                            startTimeStr: n.officeSchedule.openTimeStr,
                            endTimeStr: n.officeSchedule.closeTimeStr,
                            isOnDutyStr: "不可约诊",
                            isDefault: !0
                        }];
                        t.resolve(!0)
                    }), t.promise
                },
                v = function() {
                    f.getAllActiveRule().success(function(t) {
                        for (var i = 0; i < t.length; ++i) t[i].startTimeStr = moment("2016-01-01 " + t[i].startTime).format("HH:mm"), t[i].endTimeStr = moment("2016-01-01 " + t[i].endTime).format("HH:mm"), t[i].isOnDutyStr = t[i].isOnDuty ? "可约诊" : "不可约诊";
                        n.ruleDetailList = _.union(n.defaultRule, t)
                    })
                },
                c = function() {
                    n.officeSchedule ? v() : a().then(function() {
                        v()
                    })
                },
                p = function() {
                    if (!n.isCreateRule) {
                        n.selectedSchedule = {};
                        n.selectedSchedule.color = "#ffffff";
                        var t = $("#ruleDetailList").data("kendoGrid");
                        t.cancelChanges();
                        t.addRow();
                        n.isCreateRule = !0
                    }
                },
                w = function(n) {
                    var t = n.parents(".fullDiv").find("input[name='name']"),
                        i;
                    if (t) {
                        if (i = $(t).val(), i == undefined) return !0;
                        if (i) {
                            if (i.length > 20) return $(n.parents("td")).addClass("cell-overflow"), $(t).attr("data-nameValidation-msg", "班次不能超过20个字符!"), !1
                        } else return $(n.parents("td")).addClass("cell-overflow"), $(t).attr("data-nameValidation-msg", "班次不能为空"), !1
                    }
                    return !0
                },
                b = function() {
                    var i = {
                            "class": "table-header-cell",
                            style: "text-align: center; font-weight: bolder"
                        },
                        f = $(window).height() - 200,
                        r;
                    n.ruleDetailList && (l = !0, r = t.find("#ruleDetailList"), r.kendoGrid({
                        dataSource: {
                            data: n.ruleDetailList,
                            schema: {
                                model: {
                                    id: "id",
                                    fields: {
                                        id: {
                                            defaultValue: 0
                                        },
                                        name: {
                                            validation: {
                                                nameValidation: w
                                            }
                                        },
                                        startTimeStr: {
                                            validation: {
                                                startTimeStrValidation: function(n) {
                                                    if (n.is("[name=startTimeStr]")) {
                                                        var t = n.data("kendoTimePicker").value();
                                                        if (!moment(t).isValid()) return n.attr("data-startTimeStrValidation-msg", "上班时间格式不正确"), !1
                                                    }
                                                    return !0
                                                }
                                            },
                                            defaultValue: n.officeSchedule.openTimeStr
                                        },
                                        endTimeStr: {
                                            validation: {
                                                endTimeStrValidation: function(n) {
                                                    if (n.is("[name=endTimeStr]")) {
                                                        var t = n.data("kendoTimePicker").value();
                                                        if (!moment(t).isValid()) return n.attr("data-endTimeStrValidation-msg", "下班时间格式不正确"), !1
                                                    }
                                                    return !0
                                                }
                                            },
                                            defaultValue: n.officeSchedule.closeTimeStr
                                        },
                                        color: {
                                            defaultValue: "#ffffff"
                                        },
                                        isOnDutyStr: {
                                            defaultValue: "可约诊"
                                        }
                                    }
                                }
                            }
                        },
                        scrollable: !0,
                        height: f,
                        selectable: "single",
                        editable: {
                            mode: "inline",
                            createAt: "bottom"
                        },
                        change: function() {
                            var t = this.dataItem(this.select());
                            t.id && u(function() {
                                n.selectedSchedule = t
                            })
                        },
                        dataBound: d,
                        columns: [{
                            field: "name",
                            title: "班次",
                            width: "150px",
                            headerAttributes: i,
                            template: kendo.template($("#colorTemplate").html()),
                            editor: function(t, i) {
                                var f = i.model.color == "#ffffff" ? "black" : "#ffffff",
                                    r, u;
                                n.isShowColor = !0;
                                r = k(i);
                                u = $(r);
                                u.appendTo(t);
                                rt(i, t)
                            }
                        }, {
                            field: "startTimeStr",
                            title: "上班时间",
                            width: "80px",
                            headerAttributes: i,
                            editor: function(n, t) {
                                var i = $('<input name="' + t.field + '"/>'),
                                    r;
                                i.appendTo(n);
                                i.kendoTimePicker({
                                    interval: 30
                                });
                                r = $('<span class="k-invalid-msg" data-for="' + t.field + '"><\/span>');
                                r.appendTo(n)
                            }
                        }, {
                            field: "endTimeStr",
                            title: "下班时间",
                            width: "60px",
                            headerAttributes: i,
                            editor: function(n, t) {
                                var i = $('<input name="' + t.field + '"/>'),
                                    r;
                                i.appendTo(n);
                                i.kendoTimePicker({
                                    interval: 30
                                });
                                r = $('<span class="k-invalid-msg" data-for="' + t.field + '"><\/span>');
                                r.appendTo(n)
                            }
                        }, {
                            field: "isOnDutyStr",
                            title: "是否可约诊",
                            width: "60px",
                            headerAttributes: i,
                            editor: function(t, i) {
                                var r = $('<input name="' + i.field + '" type="text" />');
                                r.appendTo($(t));
                                r.kendoDropDownList({
                                    dataTextField: "name",
                                    dataValueField: "name",
                                    value: i.model.isOnDutyStr,
                                    select: function(t) {
                                        var u = this,
                                            f = u.dataItem(t.item)[u.options.dataValueField],
                                            i, r;
                                        f == "不可约诊" ? (t.sender.element.parents("tr").find("#colorDiv").css("background-color", "#a9a9a9"), t.sender.element.parents("tr").find("#colorDiv").css("cursor", "default"), t.sender.element.parents("tr").find("#colorIcon").css("color", "#a9a9a9"), n.allowClick = !1) : (n.selectedSchedule && (i = n.selectedSchedule.color == "#ffffff" ? "black" : "#ffffff", r = n.selectedSchedule.color, n.selectedSchedule.color == "#a9a9a9" && (r = n.selectedSchedule.color = "#ffffff", i = "black"), t.sender.element.parents("tr").find("#colorDiv").css("background-color", r), t.sender.element.parents("tr").find("#colorDiv").css("cursor", "pointer"), t.sender.element.parents("tr").find("#colorIcon").css("color", i)), n.allowClick = !0)
                                    },
                                    dataSource: [{
                                        id: 1,
                                        name: "可约诊"
                                    }, {
                                        id: 0,
                                        name: "不可约诊"
                                    }]
                                })
                            }
                        }, {
                            command: [{
                                name: "编辑",
                                text: "编辑",
                                click: g,
                                className: "fa fa-edit rule-btn"
                            }, {
                                name: "保存",
                                text: "保存",
                                click: nt,
                                className: "fa fa-check hide rule-btn"
                            }, {
                                name: "取消",
                                text: "取消",
                                click: tt,
                                className: "fa fa-close hide rule-btn"
                            }, {
                                name: "删除",
                                text: "删除",
                                click: it,
                                className: "fa fa-trash-o rule-btn"
                            }],
                            title: "",
                            width: "120px"
                        }],
                        edit: function(n) {
                            n.container.find(".k-grid-编辑,.k-grid-删除").addClass("hide");
                            n.container.find(".k-grid-保存,.k-grid-取消").removeClass("hide")
                        }
                    }))
                },
                k = function(t) {
                    var i = t.model.color == "#ffffff" ? "black" : "#ffffff",
                        r = "pointer";
                    return t.model.color == "#a9a9a9" ? (n.allowClick = !1, r = "default", i = "#a9a9a9") : n.allowClick = !0, '<div class="fullDiv" style="position:relative;" ><div onclick="showColor(this)"><div id="colorDiv" style="width:30px;height:30px;background-color:' + t.model.color + ";border-radius:30px;position: absolute;z-index:999;cursor:" + r + ';border:solid #808080 1px" ><span id="colorIcon" class="glyphicon glyphicon-triangle-bottom" style="color:' + i + ';padding-top:7px;"><\/span><\/div><div style="position: absolute;width:20px;height:20px;overflow:auto;top:5px;left:5px;"><input id="colorPicker" type="color" /><\/div><\/div><input type="text" name="name" class="form-control" style="width:150px;max-width:150px;margin-left: 50px;" value="' + t.model.name + '" /><\/div> '
                },
                d = function() {
                    var n = this;
                    $(t).find("#ruleDetailList table tbody tr").each(function(t, i) {
                        var r = n.dataItem(i),
                            u = r.color == "#ffffff" ? "black" : "#ffffff",
                            f = "solid " + u + " 1px";
                        r.color ? ($(i).find("#colorDiv").css("background-color", r.color), $(i).find("#colorDiv").css("border", "solid #808080 1px")) : ($(i).find("#colorDiv").css("background-color", "#ffffff"), $(i).find("#colorDiv").css("border", "solid #808080 1px"));
                        r.isDefault && $(i).find(".rule-btn").remove()
                    })
                },
                g = function(t) {
                    var e = this,
                        i, r, f;
                    (n.uid && u(function() {
                        var i = $(t.currentTarget).closest("table").find('tr[data-uid="' + n.uid + '"]'),
                            r = i.find("td").find("#colorDiv"),
                            u = e.dataItem(i);
                        r.css("background-color", u.color)
                    }, 200), u(function() {
                        n.uid = $(t.currentTarget).closest("tr").attr("data-uid")
                    }, 300), t.preventDefault(), n.isCreateRule = !1, i = $(t.currentTarget).closest("tr"), r = this.dataItem(i), r && r.id) && (n.allowClick = !0, f = $("#ruleDetailList").data("kendoGrid"), f.editRow(i))
                },
                nt = function(t) {
                    var i, o, u;
                    if (n.uid = null, t.preventDefault(), i = $(t.currentTarget).closest("tr"), o = i.data("kendoValidator"), o.validate()) {
                        var r = this.dataItem(i),
                            a = i.find("input[name='startTimeStr']").data("kendoTimePicker"),
                            v = i.find("input[name='endTimeStr']").data("kendoTimePicker"),
                            s = $(i.find("input[name='name']")[0]).val(),
                            h = moment(a.value()),
                            l = moment(v.value());
                        if (r.color = r.isOnDutyStr == "可约诊" ? r.color : "#a9a9a9", u = {
                                startTime: h.format("HH:mm"),
                                endTime: l.format("HH:mm"),
                                id: r.id,
                                name: s,
                                color: r.color,
                                isOnDuty: r.isOnDutyStr == "可约诊" ? !0 : !1
                            }, !s) {
                            e.info("信息", "请输入班次！");
                            return
                        }
                        if (h >= l) {
                            e.info("信息", "上班时间必须早于下班时间！");
                            return
                        }
                        n.isCreateRule ? f.addRule(u).success(function() {
                            n.showNotification("保存成功！");
                            n.isCreateRule = !1;
                            c()
                        }).error(function(n) {
                            e.info("信息", n.message)
                        }) : f.updateRule(u).success(function() {
                            n.showNotification("保存成功！");
                            c()
                        }).error(function(n) {
                            e.info("信息", n.message)
                        })
                    }
                },
                tt = function(t) {
                    n.uid = null;
                    t.preventDefault();
                    var i = $("#ruleDetailList").data("kendoGrid");
                    i.cancelChanges();
                    n.isCreateRule = !1
                },
                it = function(n) {
                    n.preventDefault();
                    var t = this.dataItem($(n.currentTarget).closest("tr"));
                    t && t.id && e.confirm("删除", "如果删除班次规则，今后的排班记录均会被删除，确认删除？").then(function() {
                        f.logicDeleteRule(t.id).success(function() {
                            c()
                        })
                    })
                },
                rt = function(t, i) {
                    $(i).find("#colorPicker").kendoColorPicker({
                        columns: 5,
                        tileSize: 32,
                        change: function(n) {
                            $(i).find("#colorDiv").css("background-color", n.value);
                            n.value == "#ffffff" ? $(i).find("#colorIcon").css("color", "black") : $(i).find("#colorIcon").css("color", "#ffffff");
                            t.model.color = n.value
                        },
                        close: function() {
                            n.isShowColor = !0
                        },
                        palette: ["#FFD9D9", "#FFC2C2", "#FFAAAA", "#FF7C7C", "#FFE1BE", "#FFCD93", "#FFBF75", "#FFAF51", "#ACFDCE", "#62EC9B", "#A8F4E3", "#62E3C6", "#BEE3FF", "#8DCEFF", "#E5E2FF", "#FFF0A3", "#FFE663", "#E7FFB3", "#D7FF81", "#ffffff"]
                    })
                };
            (function() {
                n.switchState = y;
                n.createRuleDetail = p;
                c();
                n.$watch("ruleDetailList", function() {
                    if (l) {
                        var t = $("#ruleDetailList").data("kendoGrid");
                        t.dataSource.data(n.ruleDetailList)
                    } else b()
                });
                n.$on("$destroy", function() {
                    delete r.showColor
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleTenantCell", ["$log", "$timeout", "$filter", "loginContext", function(n, t, i, r) {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-tenant-cell.html",
        link: function(n, t) {
            (function() {
                n.$evalAsync(function() {
                    var l = r.officeId,
                        o = t.attr("groupIndex"),
                        s = t.attr("itemIndex"),
                        a = t.attr("itemKey"),
                        v = t.attr("isDoctorMode"),
                        f, u = {},
                        h, c, e;
                    v == 1 ? (f = n.officeSchedule.doctorSchedules, u = f[s].schedules[o].schedules[0]) : (f = n.officeSchedule.groupSchedule, u = f[a][s].schedules[o].schedules[0]);
                    h = u.ruleName;
                    c = i("toOfficeAbbr")(u.officeId);
                    t.find(".schedule-cell-normal").css("background-color", u.color);
                    t.find(".schedule-rule-name").text(h);
                    e = t.find(".schedule-office-abbr");
                    e.children("td").text(c);
                    l != u.officeId ? e.show() : e.hide()
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleTenantContentDoctorView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-tenant-content-doctor-view.html",
        scope: {
            officeSchedule: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleTenantContentPersonnelView", ["$log", function() {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-tenant-content-personnel-view.html",
        scope: {
            officeSchedule: "="
        },
        link: function(n) {
            (function() {
                n.$watch("officeSchedule", function() {
                    n.officeSchedule && (n.title = n.officeSchedule.office.name + "(" + n.officeSchedule.doctorSchedules.length + "位)")
                })
            })()
        }
    }
}]);
scheduleRuleModule.directive("scheduleTenantListView", ["$log", "$modal", "$q", "$window", "$timeout", "scheduleSvc", "aresDialog", "appNav", "officeSvc", function(n, t, i, r, u) {
    return {
        restrict: "E",
        templateUrl: "/app/schedule-rule/views/schedule-tenant-list-view.html",
        controller: "SchedulerTenantListCtrl",
        link: function(n, t) {
            var c = {
                    scrollButtons: {
                        enable: !1
                    },
                    autoHideScrollbar: !0,
                    scrollInertia: 150,
                    advanced: {
                        updateOnContentResize: !0
                    }
                },
                p = function() {
                    f();
                    var n = angular.element(r);
                    t.find(".tenant-content").mCustomScrollbar(c);
                    n.on("resize", function() {
                        f()
                    })
                },
                f = function() {
                    var i = angular.element(r).height(),
                        u = i - 240 - (window.Ares3 ? 25 : 0),
                        n = t.find(".tenant-content");
                    n.height(u);
                    n.data("mCustomScrollbarIndex") ? n.mCustomScrollbar("update") : n.mCustomScrollbar(c)
                },
                w = function() {
                    t.find("#officeInput").kendoDropDownList({
                        dataTextField: "name",
                        dataValueField: "id",
                        value: n.officeId,
                        select: function(t) {
                            var i = this,
                                r = i.dataItem(t.item)[i.options.dataValueField];
                            r && u(function() {
                                n.officeId = r;
                                n.clearSelectedSchedule();
                                n.initDoctorSchedule()
                            })
                        },
                        dataSource: n.offices
                    })
                },
                l = 20,
                e = 0,
                o = !1,
                s = !1,
                a = !1,
                i = 0,
                v = 0,
                h = function() {
                    var t, r;
                    n.pageIndex++;
                    t = n.doctorSchedulesArray;
                    e = l * n.pageIndex;
                    r = -1;
                    n.pageIndex > 0 && (r = l * (n.pageIndex - 1));
                    _.each(t, function(t, u) {
                        u >= r && u < e && n.officeSchedules[i].doctorSchedules.push(t)
                    });
                    o = !1;
                    t.length == n.officeSchedules[i].doctorSchedules.length && (v = t.length, i = 2, a = !0);
                    n.pageIndex > 1 && n.$apply()
                },
                b = t.find("#schedule");
            b.scroll(function(n) {
                var t = n.currentTarget.scrollTop,
                    i = n.currentTarget.clientHeight,
                    u = parseInt((i - 37) / 46) + 1,
                    f = e * 46 + 37,
                    c = f - i,
                    r;
                t > c ? o || (requestAnimationFrame(h), o = !0) : a && (r = parseInt((t - 37) / 46) + 1 + u, r == v && (s || (requestAnimationFrame(y), s = !0)))
            });
            var k = function() {
                    _.each(n.officeSchedules, function(t, i) {
                        n.officeSchedules[i].doctorSchedules = []
                    })
                },
                y = function() {
                    var t = n.officeSchedulesArray;
                    _.each(t, function(r, u) {
                        i == u && (n.doctorSchedulesArray = angular.copy(t[i].doctorSchedules), n.pageIndex = 0, h())
                    });
                    s = !1
                },
                d = function(t) {
                    n.date = t;
                    n.getDateRange();
                    n.initDoctorSchedule()
                },
                g = function(n) {
                    var r = t.find(".worker-btns"),
                        i = "";
                    i = n ? "btn-doctor" : "btn-worker";
                    r.children("." + i + "").addClass("btn-primary").siblings("button").removeClass("btn-primary")
                };
            (function() {
                n.$watch("offices", function() {
                    n.offices && w()
                });
                p();
                n.initTableView = f;
                n.getDoctorSchedules = h;
                n.screenOfOneLoad = y;
                n.cleanDoctorSchedules = k;
                n.searchByDate = d;
                n.workerChange = g
            })()
        }
    }
}]);
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.providerResource.rule"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ProviderResourceRuleView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.providerResource.view"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ProviderResourceViewView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.rule"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleRuleViewNew", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.setting.fixed"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleSettingFixedView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.settingView.monthly"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleSettingMonthlyBrowseView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.setting.monthly"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleSettingMonthlyView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.settingView.weekly"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleSettingWeeklyBrowseView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));
var scheduleRule;
(function() {
    "use strict";
    var n = function() {
        function n() {
            this.restrict = "E";
            this.replace = !0;
            this.template = '\n            <div class="schedule-rule-view-new" style="width: 100%; height: 100%;">\n                <ares-new-home-view target-route="officeSettings.schedule.setting.weekly"><\/ares-new-home-view>\n            <\/div>\n        '
        }
        return n.$inject = [], n
    }();
    scheduleRuleModule.directive("ares3ScheduleSettingWeeklyView", Ares.tsDirective(n))
})(scheduleRule || (scheduleRule = {}));